local fenfeng = fk.CreateSkill {
  name = "th_fenfeng",
  max_turn_use_time = 1,
}

fenfeng:addEffect(fk.DamageFinished, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(fenfeng.name) and not player:isNude()
      and data.dealtRecorderId and not data.chain and data.damageType ~= fk.NormalDamage and data.damage > 0
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local anothers = table.filter(room:getOtherPlayers(player, false), function(p) return p ~= target end)
    local discard = table.filter(player:getCardIds("he"), function(cid)
      return not player:prohibitDiscard(cid)
    end)
    local tos, card = room:askToChooseCardsAndPlayers(player, {
      targets = anothers,
      min_num = 1,
      max_num = 1,
      min_card_num = 1,
      max_card_num = 1, 
      prompt = "#th_fenfeng-invoke:"..target.id,
      pattern = tostring(Exppattern:new{ id = discard }),
      skill_name = fenfeng.name,
      cancelable = true
    })
    if #tos > 0 then
      event:setCostData(self, { tos = tos, cards = card })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local dat = event:getCostData(self)
    local to = dat.tos[1]
    room:throwCard(dat.cards, fenfeng.name, player, player)
    local cards = room:askToDiscard(to, {
      min_num = 2,
      max_num = 2,
      include_equip = true,
      skill_name = fenfeng.name,
      cancelable = true,
      prompt = "#th_fenfeng-cost:"..target.id
    })
    if #cards < 2 then
      room:sendLog{
        type = "#ChainDamageWithoutChain",
        from = to.id
      }
      local dmg = {
        from = data.from,
        to = to,
        damage = data.damage,
        damageType = data.damageType,
        card = data.card,
        skillName = data.skillName,
        chain = true,
      }
      room:damage(dmg)
    end
  end
}, { check_skill_limit = true })

Fk:loadTranslationTable{
  ["th_fenfeng"] = "焚风",
  [":th_fenfeng"] = "每回合限一次，一名角色受到非连环属性伤害结算结束后，你可以弃置一张牌并令另一名其他角色选择一项：1.弃置两张牌；2.<a href=desc_#ChainDamageWithoutChain>被传导伤害</a>。",

  ["desc_#ChainDamageWithoutChain"] = '#关于"<b>被传导伤害</b>"<br>' ..
  '1.被传导伤害结算流程与一般的传导伤害一致，不会触发连环结算；<br>' ..
  "2.若来源伤害未触发连环，则其在视为传导伤害时不会被视为连环起点，也不会触发连环结算。",

  ["#th_fenfeng-invoke"] = "焚风：你可以弃置一张牌令另一名其他角色弃牌或受到由 %src 传导的伤害",
  ["#th_fenfeng-cost"] = "焚风：你需弃置两张牌，否则你将受到由 %src 传导的伤害",

  ["#ChainDamageWithoutChain"] = "%from 将受到传导的伤害",
}

return fenfeng